/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Traitement;

import test_porte_variable.Machine;

/**
 *
 * @author phoebus du F.L.A.L.
 */
public class Extraire {

    /**
     * Procedure qui affecte les valeurs de la phrase APT Toute les valeur axe,
     * vitesses, outils seront à jour aprés etre passé dans cette procédure
     *
     * @param phrase
     */
    public static void extraction(String[] phrase) {

        String appel_pivot = null;


        if (phrase[0]!=null) {
            
        
        switch (phrase[0]) {


            case "GOTO"://GOTO  /    5.90769,    0.00000,   12.40000
//                    Machine.fen.SetIso("G0 ");
                Machine.x.setValeur(Double.valueOf(phrase[1]));
//                    Machine.fen.SetIso("X " + phrase[1] + " ");
                Machine.y.setValeur(Double.valueOf(phrase[2]));
//                    Machine.fen.SetIso("Y " + phrase[2] + " ");
                Machine.z.setValeur(Double.valueOf(phrase[2]));
//                    Machine.fen.SetIso("Z " + phrase[3] + "\r\n");
                appel_pivot = "DEPLACEMENT";
                break;
            case "PARTNO"://PARTNO 1040
                Machine.nop.setValeur(Double.valueOf(phrase[1]));
                appel_pivot = "PARTNO";
                break;

            case "LOADTL"://LOADTL/3,ADJUST,3
                Machine.nooutil.setValeur(Double.valueOf(phrase[1]));
                Machine.correcteur.setValeur(Double.valueOf(phrase[3]));
                appel_pivot = "LOAD_TOOL";
                break;

            case "SPINDL"://SPINDL/  200.0000,SMM,CCLW
                switch (phrase[1]) {
                    case "OFF":
                        Machine.sens_rotation.affecte(phrase[1]);
                        appel_pivot = "SPINDL";
                        break;
                    default:
                        Machine.frequence_rotation.setValeur(Double.valueOf(phrase[1]));
                        Machine.sens_rotation.affecte(phrase[3]);
                        Machine.unite_rotation.affecte(phrase[2]);
                        appel_pivot = "SPINDL";
                        break;
                }


                break;

            case "COOLNT"://COOLNT/0N
                switch (phrase[1]) {
                    case "ON":

                        Machine.lalub.setinstruction("ON");
                        break;
                    case "OFF":
                        Machine.lalub.setinstruction("OFF");

                        break;
                    case "HOLL":
                        Machine.lalub.setinstruction("HOLL");

                        break;
                    case "MIST":
                        Machine.lalub.setinstruction("MIST");

                        break;
                    default:
                        Machine.lalub.setinstruction("ON");
                        break;
                }
                appel_pivot = "COOLNT";
                break;

            case "RAPID":
                Machine.interpol.affecte("RAPID");
                break;

            case "FEDRAT"://FEDRAT/    0.3000,MMPR
                Machine.f.setValeur(Double.valueOf(phrase[1]));
                Machine.unite_avance.affecte(phrase[2]);
                Machine.interpol.affecte("PROGRAMME");
                break;

            case "PPRINT"://PPRINT/T6 Foret ø4
                Machine.comment.setValeur(phrase[1]);
                appel_pivot = "COMMENT";
                break;
            case "END"://end
                Machine.fin_prog.setinstruction("END");
                appel_pivot = "END_PROG";
                break;
             default:
                break;  
        }
        }

        if (appel_pivot != null) {
            Formate.iso(Pivot.pivot(appel_pivot));
            appel_pivot = null;
        }

    }
}
